home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93b.txt
/
000093_icon-group-sender _Sun May 16 17:30:41 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1993-06-16
|
2KB
Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 17 May 1993 07:43:30 MST
Received: by owl.cs.arizona.edu; Mon, 17 May 1993 07:43:29 MST
Date: 16 May 93 17:30:41 GMT
From: sdd.hp.com!portal!cup.portal.com!Eric-Amick@hplabs.hpl.hp.com (Richard E Amick)
Organization: The Portal System (TM)
Subject: Re: string stripping
Message-Id: <81483@cup.portal.com>
References: <12646.9305141703@desktop.desktop.co.uk>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
>procedure main()
>
>full := "abc-def.ghi"
>bare := ""
>badchars := '-.'
>
>full ? {
> while bare ||:= tab(many(~badchars)) do
> tab(many(badchars))
>}
>write(bare)
>
>end
>
>You may notice that despite my suggestion of using "upto()"
>I actually used tab(many(~badchars)). This allows you to include
>any trailing good characters as a part of the loop processing
>rather than having to program in possible special cases.
>
>This group being what it is you may well get several other good
>(possibly even better :-) ideas on how to go about this.
Your solution won't work if the string starts off with bad characters.
On the other hand, making the scanning loop read as follows works:
while tab(upto(~badchars)) do
bare ||:= tab(many(~badchars))
The only likely objection might be that creating what is almost always a
large cset of good characters is inefficient, but I don't think that's a
horrible thing in this case (and Icon is not renowned for blazing speed
anyway :-). Maybe you should have taken your own advice about upto(),
eh? ;-)
>
>regards
> Steve